#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
typedef struct
{
    int month;
    int day;
    int year;
}date;

int main()
{
    int n;
    scanf("%d", &n);

    date a[100];  //定义日期结构体数组
    for (int i = 0; i < n; i++)
        scanf("%d/%d/%d", &a[i].month, &a[i].day, &a[i].year);

    for (int i = 0; i < n - 1; i++)
        for (int j = 0; j < n - 1 - i; j++)
        {
            if (a[j].year > a[j + 1].year || a[j].year == a[j + 1].year && a[j].month > a[j + 1].month
                || a[j].year == a[j + 1].year && a[j].month == a[j + 1].month && a[j].day > a[j + 1].day)  //&&的优先级比||高
            {
                date t = a[j];
                a[j] = a[j + 1];
                a[j + 1] = t;
            }
        }

    for (int i = 0; i < n; i++)
        printf("%02d/%02d/%d\n", a[i].month, a[i].day, a[i].year);
    return 0;
}